1

mysqldb

c=db.cursor()
max_price=5
c.execute("""SELECT spam, eggs, sausage FROM breakfast
          WHERE price < %s""", [max_price])

sqlalchemy

from sqlalchemy.sql import text
t = text("select * from test where id= :tid")
conn.execute(t, tid=1).fetchall()

flask-sqlalchemy

db = SQLAlchemy(app)
conn = db.session.connection()

@app.route('/')
def index():
    rv = conn.execute('select * from test where id = %s', [1])
    return jsonify(rv)

icheeringsoul
48 声望6 粉丝